package com.ace3l.legal.gwt.domainmodule.client;

import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.core.client.GWT;
import com.ace3l.legal.gwt.domainmodule.gwt.GWTLawFirm;
import com.ace3l.legal.gwt.domainmodule.gwt.GWTStudent;
import com.synesthesiaconsulting.gwt.resources.client.GWTUtils;
import com.synesthesiaconsulting.gwt.resources.client.MsgObjBundle;

/**
 * Created by IntelliJ IDEA.
 * User: ageer
 * Date: Jul 22, 2008
 * Time: 10:24:25 AM
 * To change this template use File | Settings | File Templates.
 */
public interface UserService extends RemoteService {
    /**
     * Utility/Convenience class.
     * Use UserService.App.getInstance() to access static instance of UserServiceAsync
     */
    public static class App {
        private static UserServiceAsync ourInstance = null;

        public static synchronized UserServiceAsync getInstance() {
            if (ourInstance == null) {
                ourInstance = (UserServiceAsync) GWT.create(UserService.class);
                
                if (GWT.isScript()) {
                    ((ServiceDefTarget) ourInstance).setServiceEntryPoint(GWTUtils.getUrlWithContext() + "/gwt/UserService");
                } else {
                    ((ServiceDefTarget) ourInstance).setServiceEntryPoint(GWT.getModuleBaseURL() + "com.ace3l.legal.gwt.domainmodule.Ace3LDomainModule/UserService");
                }
            }
            return ourInstance;
        }
    }

    public Boolean authenticateUser(String username, String password);
    public MsgObjBundle createLawFirm(GWTLawFirm lawFirm);
    public MsgObjBundle createStudent(GWTStudent student);
    public GWTLawFirm getLawFirm(Integer id);
    public void logoutUser();
    public String getRole();
    public Boolean doesUserExist(String username);

}
